package TestDemo;

import java.util.Scanner;

class Dfs {
    public int res;
    private boolean[] st;

    Dfs(int n) {
        st = new boolean[n];
    }

    public void dfs(int u, int ans, int[] arr) {
        if (u == 3) {
            res += ans;
        }

        for (int i = 0; i < st.length; i++) {
            if (!st[i]) {
                st[i] = true;
                dfs(u + 1, ans * 10 + arr[i], arr);
                st[i] = false;
            }
        }
    }
}

public class Problem1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        Dfs d = new Dfs(n);
        d.dfs(0,0,arr);

        System.out.println(d.res);
    }
}
